
class_name CangLanJian


static func CreateCardData() -> CardData:
	var data = CardData.new()
	
	data.attack = 30
	data.hp = 240
	data.maxHp = data.hp
	data.defence = 10
	data.speed = 8
	
	data.cardName = "沧澜剑"
	data.cardDesc = "攻击目标+1"
	data.image = load("res://texture/Role/沧澜剑.png")
	
	return data


static func CreateCard() -> Card:
	var cardprefab = load("res://prefab/card.tscn")
	var card: Card = cardprefab.instantiate()
	
	
	var data: CardData = CreateCardData()
	data.onAttack = func(targets: Array):
		if targets.is_empty():
			return
		
		var target: Card = targets.pick_random()
		var target2: Card = targets.pick_random()
		
		var damage = data.attack
		var result_damage = target.data.onDefence.call(damage)
		var result_damage2 = target2.data.onDefence.call(damage)
		
		var endCall = func ():
			target.data.onHurt.call(result_damage)
			target.runHurtAnim(result_damage)
		
		card.runAttackAnim(target, endCall)
		
		var endCall2 = func ():
			target2.data.onHurt.call(result_damage2)
			target2.runHurtAnim(result_damage2)
		
		card.runAttackAnim(target2, endCall2)
		
		data.lastAttackTime = Time.get_ticks_msec()
	
	card.setData(data)
	
	return card
	


	
